package com.jy.rhin.support.polymorphism.convertor;

import cn.org.chiss.rhin._2015.document.management.DocumentStoredQueryResponse;
import com.jy.rhin.sdk.dto.document.DocumentFolderDto;
import com.jy.rhin.sdk.dto.document.DocumentResultDto;
import com.jy.rhin.sdk.dto.document.query.GetFoldersDto;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author dhl
 * @date 2022/6/22
 * @Description
 */
@Service("getFolders")
public class DocumentQueryHandler4GetFolders extends AbstractDocumentQueryHandler<GetFoldersDto, DocumentFolderDto>{
    @Override
    GetFoldersDto convertReq(Map<String, List<String>> dtoValueMap) {
        GetFoldersDto dto = new GetFoldersDto();
        dto.setIdList(QueryValueUtils.getListValue("$FolderUUID", dtoValueMap));
        dto.setUniqueIdList(QueryValueUtils.getListValue("$FolderUniqueId", dtoValueMap));
        dto.setHomeCommunityId(QueryValueUtils.getStringValue("$HomeCommunityId", dtoValueMap));
        return dto;
    }

    @Override
    DocumentResultDto<DocumentFolderDto> query(GetFoldersDto dto) {
        return documentSubmissionQueryHandler.getFolders(dto);
    }

    @Override
    DocumentStoredQueryResponse convertResp(List<DocumentFolderDto> resultList, List<String> jsonTextList) {
        return folderConvert(resultList, jsonTextList);
    }
}
